package com.kvest.view_pager_test.adapter;

import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.View;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Kvest
 * Date: 17.03.13
 * Time: 17:18
 * To change this template use File | Settings | File Templates.
 */
public class TestPagerAdapter extends PagerAdapter {
    private static final String LOG_TAG = TestPagerAdapter.class.getName();

    private List<View> pages = null;
    public TestPagerAdapter(List<View> pages) {
        super();

        this.pages = pages;
    }

    @Override
    public Object instantiateItem(View container, int position){
        View v = pages.get(position);
        ((ViewPager) container).addView(v, 0);
        return v;
    }

    @Override
    public void destroyItem(View container, int position, Object view){
        ((ViewPager) container).removeView((View) view);
    }

    @Override
    public int getCount(){
        return pages.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object){
        Log.d(LOG_TAG, "isViewFromObject");
        return view.equals(object);
    }

    @Override
    public void finishUpdate(View arg0){
        Log.d(LOG_TAG, "finishUpdate");
    }

    @Override
    public void restoreState(Parcelable arg0, ClassLoader arg1){
        Log.d(LOG_TAG, "restoreState");
    }

    @Override
    public Parcelable saveState(){
        Log.d(LOG_TAG, "saveState");
        return null;
    }

    @Override
    public void startUpdate(View arg0){
        Log.d(LOG_TAG, "startUpdate");
    }

}
